package com.demo;

public interface dao {
    public void Add();
}

两个实现类：
public class StudentDao implements dao {
    @Override
    public void Add() {

    }
}

public class CourseDao implements dao {

    @Override
    public void Add() {

    }
}

两个工厂类：
public class SendMailFactory implements Provider {

    @Override
    public dao produce(){
        return new StudentDao();
    }
}

public class DaoFactory implements Provider{

    @Override
    public dao produce() {
        return new CourseDao();
    }
}
接口：
public interface Provider {
    public dao produce();
}
